﻿using System.IO.Ports;
using AppServer.Core;
namespace AppServer.Implement.SerialPort
{
    /// <summary>
    /// SerialPort服务器配置
    /// </summary>
    public class SerialPortConfig : IServerConfig
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="comm">端口号</param>
        /// <param name="baudRate">波特率</param>
        /// <param name="parity">校验</param>
        /// <param name="bits">数据位</param>
        /// <param name="stop">停止位</param>
        public SerialPortConfig(byte comm,int baudRate,Parity parity=Parity.None,int bits=8,StopBits stop=StopBits.One)
        {
            this.CommName = string.Format("COM{0}", comm);
            this.BaudRate = baudRate;
            this.Parity = parity;
            this.Bits = bits;
            this.Stop = stop;
        }

        /// <summary>
        /// 端口号
        /// </summary>
        public string CommName
        {
            get;
            private set;
        }

        /// <summary>
        /// 波特率
        /// </summary>
        public int BaudRate
        {
            get;
            private set;
        }

        /// <summary>
        /// 校验位
        /// </summary>
        public Parity Parity
        {
            get;
            private set;
        }

        /// <summary>
        /// 数据位
        /// </summary>
        public int Bits
        {
            get;
            private set;
        }

        /// <summary>
        /// 停止位
        /// </summary>
        public StopBits Stop
        {
            get;
            private set;
        }
    }
}
